package com.liumo.utils;
import com.liumo.domain.Student;
import com.liumo.domain.Teacher;
import com.liumo.domain.User;

import java.util.Scanner;

public class LoginSystem {

    private static final String TEACHER_USERNAME = "teacher";
    private static final String TEACHER_PASSWORD = "password123";
    private static final String STUDENT_USERNAME = "student";
    private static final String STUDENT_PASSWORD = "password456";

    public static User login() {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请选择登录用户（teacher/student）：");
        String username = scanner.nextLine();

        System.out.println("请输入密码：");
        String password = scanner.nextLine();

        if (username.equals(TEACHER_USERNAME) && password.equals(TEACHER_PASSWORD)) {
            return new Teacher(username, password);
        } else if (username.equals(STUDENT_USERNAME) && password.equals(STUDENT_PASSWORD)) {
            return new Student(username, password);
        } else {
            System.out.println("用户名或密码错误！");
            return null;
        }
    }
}